package com.ruoyi.controller;

import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.service.TxyService;
import com.ruoyi.utils.SimpleResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/txy")
@RestController
public class TxyController {
    @Autowired
    private TxyService liveService;

    /**
     * 获取直播推流地址[服务提供: 腾讯云]
     * @param streamName
     * @return {@code SimpleResult}
     */
    @GetMapping("/get-push-address/{streamName}")
    public SimpleResult getPushAddress(@PathVariable("streamName") String streamName) {
        String pushAddress = liveService.getPushAddress(streamName);
        return SimpleResult.success(pushAddress, "获取推流地址成功~");
    }

    /**
     * 获取直播推流地址[服务提供: 腾讯云]
     * @param streamName
     * @return {@code SimpleResult}
     */
    @GetMapping("/get-push-address-app/{streamName}")
    public SimpleResult getPushAddressApp(@PathVariable("streamName") String streamName) {
        String pushAddress = liveService.getPushAddress("rtmp://", streamName);
        return SimpleResult.success(pushAddress, "获取推流地址成功~");
    }

    /**
     * 获取播放地址[服务提供: 腾讯云]
     * @param streamName
     * @return {@code SimpleResult}
     */
    @GetMapping("/get-play-address/{streamName}")
    public SimpleResult getPlayAddress(@PathVariable("streamName") String streamName) {
        String playAddress = liveService.getPlayAddress(streamName);
        return SimpleResult.success(playAddress, "获取播放地址成功~");
    }
}
